
export default class Beans {
    static to(target){
        return JSON.parse(JSON.stringify(target));
    }

    static bean(json){
        return JSON.parse(json);
    }
    static copy(target){
        return Beans.to(target);
    }
    static replace(target, replaceJSON){
        const r = Beans.to(target);
        for(const v in replaceJSON){
            r[v] = replaceJSON[v];
        }
        return r;
    }

    static toMapByKey(arrs, key){
        const result = {};
        arrs.forEach((v)=>{
            if(v.hasOwnProperty(key)){
                result[key] = v;
            }
        });
        return result;
    }

    static json(target){
        return JSON.stringify(target)
    }

    static  strEmpty(s){
        return !!s;
    }

    static  strNotEmpty(s){
        return !s;
    }

}
